#pragma once
#include <iostream>
enum ERR
{
    Div_Zero = 1,
    Mod_Zero
};
class Task
{
public:
    Task()
    {
    }
    Task(int x, int y, char op) : data1_(x), data2_(y), oper_(op), result_(0), exitcode_(0)
    {
    }
    void Run()
    {
        switch (oper_)
        {
        case '+':
            result_ = data1_ + data2_;
            break;
        case '-':
            result_ = data1_ - data2_;
            break;
        case '*':
            result_ = data1_ * data2_;
            break;
        case '/':
        {
            if (data2_ == 0)
            {
                exitcode_ = Div_Zero;
            }
            else
                result_ = data1_ / data2_;
        }
        break;
        case '%':
        {
            if (data2_ == 0)
            {
                exitcode_ = Mod_Zero;
            }
            else
                result_ = data1_ % data2_;
        }
        break;

        default:
            std::cout << "oper error" << std::endl;
            break;
        }
    }
    std::string Result()
    {
        std::string buffer;
        buffer += std::to_string(data1_);
        buffer += oper_;
        buffer += std::to_string(data2_);
        buffer += "=";
        buffer += std::to_string(result_);
        buffer += "[code:";
        buffer += std::to_string(exitcode_);
        buffer += "]";

        return buffer;
    }
    std::string ShowTask()
    {
        std::string buffer;
        buffer += std::to_string(data1_);
        buffer += oper_;
        buffer += std::to_string(data2_);
        buffer += "=?";
        return buffer;
    }
    void operator()()
    {
        Run();
    }
    ~Task()
    {
    }

private:
    int data1_;
    int data2_;
    char oper_;
    int result_;
    int exitcode_;
};
